/**
 * 
 */
package com.vote.util;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;


public class FileOperate {
	
	public static boolean copy(File src, File dst) {
		int cnt=0;
		try {
			InputStream in = null;
			OutputStream out = null;
			try {
				in = new BufferedInputStream(new FileInputStream(src),10*1024);
				out = new BufferedOutputStream(new FileOutputStream(dst),10*1024);
				byte[] buffer = new byte[10*1024];
				
				int len=0;
				while ((len = in.read(buffer, 0, buffer.length)) > 0){
//					if(cnt>5){
//						return false;
//					}
					out.write(buffer, 0, len);
					cnt++;
				}
			}finally{
				if (null != in) {
					in.close();
				}
				if (null != out) {
					out.close();
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return true;
	}
	
	public static void main(String[] args){
		File file1=new File("d:\\sss\\chimes.wav");
		File file2=new File("d:\\sss\\test.wav");
		FileOperate.copy(file1, file2);	
	}
}
